package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.dto.NoticePageQueryDTO;
import com.sky.entity.Notice;
import org.apache.ibatis.annotations.*;

@Mapper
public interface NoticeMapper {

    @Insert("insert into notice(title, content, status, create_user, update_user) " +
            "values (#{title}, #{content}, #{status}, #{createUser}, #{updateUser})")
    void insert(Notice notice);

    Page<Notice> pageQuery(NoticePageQueryDTO noticePageQueryDTO);

    @Select("select * from notice where id = #{id}")
    Notice getById(Long id);

    void update(Notice notice);

    @Update("update notice set status = #{status} where id = #{id}")
    void updateStatus(Long id, Integer status);

    @Select("select * from notice where status = 1 order by create_time desc limit 1")
    Notice getLatestNotice();


    @Delete("DELETE FROM notice WHERE id = #{id}")
    void deleteById(Long id);
}